﻿using System;
using MikeKappel.Com.CS;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace SortingAlgorithmsTests
{

    /// <summary>
    ///This is a test class for SortingAlgorithmsTest and is intended
    ///to contain all SortingAlgorithmsTest Unit Tests
    ///</summary>
    [TestClass()]
    public class SortingAlgorithmsTest
    {
        private Int32[] UnSortedFactory(){
            return Helper.Randomize<Int32>(SortedFactory());
        }
        private Int32[] SortedFactory()
        {
            return new Int32[] { 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 };
        }
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        /// <summary>
        ///A test for ShellSort
        ///</summary>
        [TestMethod()]
        public void ShellSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.ShellSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for SelectionSort
        ///</summary>
        [TestMethod()]
        public void SelectionSortTest1()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.SelectionSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for SelectionSort
        ///</summary>
        [TestMethod()]
        public void SelectionSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.SelectionDelegate onSort = null; // TODO: Initialize to an appropriate value
            MikeKappel.Com.CS.SortingAlgorithms.SelectionSort(items, onSort);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for RadixSort
        ///</summary>
        [TestMethod()]
        public void RadixSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.RadixSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), UnSortedFactory()));
        }

        /// <summary>
        ///A test for QuickSort
        ///</summary>
        [TestMethod()]
        public void QuickSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.QuickSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for PigeonholeSort
        ///</summary>
        [TestMethod()]
        public void PigeonholeSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.PigeonholeSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for MergeSort
        ///</summary>
        [TestMethod()]
        public void MergeSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.MergeSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for InsertionSort
        ///</summary>
        [TestMethod()]
        public void InsertionSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.InsertionSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for InPlaceMergeSort
        ///</summary>
        [TestMethod()]
        public void InPlaceMergeSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.InPlaceMergeSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for GnomeSort
        ///</summary>
        [TestMethod()]
        public void GnomeSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.GnomeSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for CountingSort
        ///</summary>
        [TestMethod()]
        public void CountingSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.CountingSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for CocktailSort
        ///</summary>
        [TestMethod()]
        public void CocktailSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.CocktailSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for BucketSort
        ///</summary>
        [TestMethod()]
        public void BucketSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.BucketSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for BubbleSort
        ///</summary>
        [TestMethod()]
        public void BubbleSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.BubbleSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for BinaryTreeSort
        ///</summary>
        [TestMethod()]
        public void BinaryTreeSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.BinaryTreeSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }

        /// <summary>
        ///A test for BeadSort
        ///</summary>
        [TestMethod()]
        public void BeadSortTest()
        {
            int[] items = UnSortedFactory();
            MikeKappel.Com.CS.SortingAlgorithms.BeadSort(items);
            Assert.IsTrue(Helper.IsEqual<Int32[]>(SortedFactory(), items));
        }
    }
}
